package com.ye.utils;

import com.ye.domain.User;
import org.apache.commons.codec.digest.DigestUtils;

import java.util.UUID;

/**
 * MD5加密工具类
 */
public class Md5Util {
    public static String md5(String src) {
        return DigestUtils.md5Hex(src);
    }


    public static String createSalt() {
//        UUID生成盐
        UUID salt = UUID.randomUUID();
        return salt+"";
    }

//    token生成
    public static String signature(User user){


//        签发对象
        String iss = user.getUsername();
//        唯一标识
        String jti =user.getId()+"";
        String token = md5(iss)+""+md5(jti)+""+createSalt();
        return token;

    }






}

